$md: () !default;
$md: map-merge(
  (
    hrColor: #ddd,
    blockquoteBg: #f6f8fa,
    color-blockquote: #f6f8fa,
    blockquoteBorderColor: #ccc,
    markBg: yellow,
    kbdBg: #fafbfc,
    singleLineCoodeBg: #eeeeee,
    singleLineCoodeColor: #15a7a7,
    detailsBg: #fafafa,
    detailsBorderColor: #eaeaea,
    detailsActiveBorderColor: rgb(234, 234, 234),
    code-font: "Menlo,Monaco,Consolas,'Courier New', monospace",
    iframe-height: 40vw,
  ),
  $md
);

$color-hr: map-get($md, hrColor);
$color-blockquote-bg: map-get($md, blockquoteBg);
$color-blockquote: map-get($md, color-blockquote);
$color-blockquote-border: map-get($md, blockquoteBorderColor);
$color-mark-bg: map-get($md, markBg);
$color-kbd-bg: map-get($md, kbdBg);
$color-singlelinecode-bg: map-get($md, singleLineCoodeBg);
$color-singlelinecode: map-get($md, singleLineCoodeColor);
$color-details-bg: map-get($md, detailsBg);
$details-border-color: map-get($md, detailsBorderColor);
$details-active-border-color: map-get($md, detailsActiveBorderColor);
$font-code: map-get($md, code-font);
$height-iframe: map-get($md, iframe-height);

// tinymce5
// Markdown
#cnblogs_post_body.blogpost-body-html,
#mainContent .cnblogs-markdown {
  word-break: break-word;
  line-height: 1.75;
  font-weight: 400;
  font-size: 15px;

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    line-height: 1.5;
    margin: 35px 0 10px;
    padding: 0 0 5px 0;
  }
  h1 {
    font-size: 30px;
    margin-bottom: 5px;
  }
  h2 {
    padding-bottom: 12px;
    font-size: 24px;
    border-bottom: 1px solid $color-hr;
  }
  h3 {
    font-size: 18px;
    padding-bottom: 0;
  }
  h4 {
    font-size: 16px;
  }
  h5 {
    font-size: 15px;
  }
  h6 {
    margin-top: 5px;
  }

  p {
    margin: 22px 0;
    line-height: inherit;
  }

  img {
    display: flex;
    margin: 10px auto;
    max-width: 100% !important;
    border-radius: 4px;
  }

  hr {
    margin: 32px 0;
    border: none;
    border-bottom: 1px solid $color-hr;
  }

  code {
    font-family: $font-code;
    word-break: break-word;
    border-radius: 2px;
    overflow-x: auto;
    background-color: $color-singlelinecode-bg !important;
    color: $color-singlelinecode !important;
    font-size: 0.87em;
    padding: 2px 6px !important;
    display: inline;
  }

  a {
    color: #47a1f6;
    &:hover {
      color: #68b5fb;
    }
  }

  table {
    display: inline-block !important;
    font-size: 12px;
    width: auto;
    max-width: 100%;
    overflow: auto;
  }
  thead {
    background: none;
    text-align: left;
    th {
      background: none;
    }
  }
  tr:nth-child(2n) {
    background: none;
  }
  th,
  td {
    padding: 8px 4px;
    line-height: 24px;
  }
  td {
    min-width: 120px;
  }

  ol,
  ul {
    margin: 22px 0;
    padding: 0 0 0 28px;
    li {
      margin-bottom: 0;
    }
    ul,
    ol {
      margin-top: 4px;
    }
  }

  blockquote {
    margin: 22px 0;
    padding: 1px 22px;
    color: $color-blockquote;
    background: $color-blockquote-bg;
    border-left: 4px solid $color-blockquote-border;
    &::after {
      display: block;
      content: '';
    }
    & > p {
      margin: 10px 0;
    }
  }

  details {
    margin: 1.5rem 0;
    padding: 0.5rem 1rem;
    background: $color-details-bg;
    border-radius: 3px;
    border: 1px solid;
    border-color: $details-border-color;
    & > summary {
      font-weight: 500;
      outline: none;
      cursor: pointer;
    }
    &[open] {
      border: 1px solid $details-active-border-color;
    }
  }

  iframe {
    width: 100%;
    height: $height-iframe;
    &.music {
      width: auto;
      height: auto;
    }
  }
}

// Markdown
#mainContent .cnblogs-markdown {
  kbd {
    display: inline-block;
    padding: 3px 5px;
    font: 11px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
    line-height: 10px;
    color: #444d56;
    vertical-align: middle;
    background-color: $color-kbd-bg;
    border: 1px solid #d1d5da;
    border-radius: 2px;
    box-shadow: inset 0 -1px 0 #d1d5da;
  }
  mark {
    background-color: $color-mark-bg;
  }
}

// 评论内容 Markdown
#mainContent #blog-comments-placeholder {
  blockquote,
  p {
    margin: 4px 0;
  }
}

@media screen and (max-width: 1023px) {
  iframe {
    height: 60vw;
  }
}

@media screen and (max-width: 768px) {
  h1 {
    font-size: 24px;
  }
  h2 {
    font-size: 20px;
  }
  h3 {
    font-size: 18px;
  }
  #cnblogs_post_body,
  .cnblogs-post-body,
  .cnblogs-markdown {
    iframe {
      height: 50vw;
    }
  }
}
